cmake_minimum_required(VERSION 3.25)
project(c_aduio C)

set(CMAKE_C_STANDARD 11)

if(UNIX AND NOT APPLE)
    message("This is Linux")
    set(PortAudio_DIR_INCLUDE /usr/include)
    set(PortAudio_DIR_LIB /usr/lib/x86_64-linux-gnu)

    set(Rtmp_DIR_INCLUDE /usr/include)
    set(Rtmp_DIR_LIB /usr/lib/x86_64-linux-gnu)
    include_directories(${PortAudio_DIR_INCLUDE})
    include_directories(${Rtmp_DIR_INCLUDE})
elseif(APPLE)
    message("This is APPLE")
    set(PortAudio_DIR /opt/homebrew/Cellar/portaudio/19.7.0)
    set(PortAudio_DIR_INCLUDE ${PortAudio_DIR}/include)
    set(PortAudio_DIR_LIB ${PortAudio_DIR}/lib)

    set(Rtmp_DIR /opt/homebrew/Cellar/rtmpdump/2.4-20151223_3)
    set(Rtmp_DIR_INCLUDE ${Rtmp_DIR}/include)
    set(Rtmp_DIR_LIB ${Rtmp_DIR}/lib)
    include_directories(${PortAudio_DIR_INCLUDE})
    include_directories(${Rtmp_DIR_INCLUDE})
endif()

add_executable(c_aduio main.c g711.c g711.h)
target_link_directories(c_aduio PRIVATE ${PortAudio_DIR_LIB})
target_link_directories(c_aduio PRIVATE ${Rtmp_DIR_LIB})

if(UNIX AND NOT APPLE)
    message("This is Linux")
    target_link_libraries(c_aduio ${PortAudio_DIR_LIB}/libportaudio.so)
    target_link_libraries(c_aduio ${Rtmp_DIR_LIB}/librtmp.so)
elseif(APPLE)
    message("This is APPLE")
    target_link_libraries(c_aduio ${PortAudio_DIR_LIB}/libportaudio.dylib)
    target_link_libraries(c_aduio ${Rtmp_DIR_LIB}/librtmp.dylib)
endif()









